<?php
	include_once("adb.php");
	
	class community_members extends adb{
		function community_members(){
			adb::adb();
		}
		/**
		*query all vaccines in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_community_members(){
			$query="select community_member_id,card_number,fullname,age,birthdate,gender,household_id,community_id,registration_date, up_datedate,device_id from community_members";
			return $this->query($query);
		}
		
		function add_community_member($card_number,$fullname,$age,$birthdate,$gender,$household_id,$community_id,$registration_date,$device_id){
			$query = "INSERT INTO community_members set card_number='$card_number',
			fullname= '$fullname',
			age='$age', 
			birthdate = '$birthdate',
			gender = '$gender',
			household_id='$household_id', 
			community_id='$community_id',
			registration_date = '$registration_date',
			device_id='$device_id'";
			return $this->query($query);
		}
		
		function update_community_members($community_member_id,$card_number,$fullname,$age,$birthdate,$gender,$household_id,$community_id,$registration_date, $up_datedate,$device_id){
			$query = "UPDATE community_members set
			card_number='$card_number',
			fullname= '$fullname',
			age='$age', 
			birthdate = '$birthdate',
			gender = '$gender',
			household_id='$household_id', 
			community_id='$community_id',
			registration_date = '$registration_date',
			up_datedate = '$up_datedate',
			device_id='$device_id' where community_member_id='$community_member_id'";
			
			
			return $this->query($query);
		}

		function search_community_members($memberName)
			{
				$query = "select * from community_members where fullname like '%$memberName%'";
				
				return $this -> query($query);
				
			}
		
		function get_community_members($id)
			{
				$query = "select * from community_members where community_member_id = $id";
				if(!$this -> query($query))
				{
					return false;
				}
					return $this -> fetch();
			}
        function delete_community_member($community_member_id)
        {
            $query = "delete from community_members where
			community_member_id='$community_member_id'";

            return $this -> query($query);
        }
		
	}
	
	//call methods here to test
	/*$obj = new community_members();
	if(!$obj->get_all_community_members())
	{
	echo "error";
	}
	
	$row = $obj->fetch();
	while($row){
	print_r($row);
	$row = $obj->fetch();
	}*/
?>